package src.com.hpu.parser;

import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import android.util.Log;
import com.hpu.bean.Book;

public class BookParser{

	public List<Book> parse(String parseString) {
		List<Book> books = new ArrayList<>();
		try {
			JSONArray array = new JSONArray(parseString);
			for(int i=0;i<array.length();i++){
				JSONArray array2=array.getJSONArray(i);
				String name=array2.getString(0);
				String author=array2.getString(1);
				String address=array2.getString(2);
				String year=array2.getString(3);
				String index=array2.getString(4);
				String tag=array2.getString(5);
				String language=array2.getString(6);
				Book book=new Book(name, author, address, year, index, language, tag);
				books.add(book);
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return books;
	}
}
